BitIO
 
 
 Bean BitIO
 
General 1-bit Input/Output

Typical usage of the bean in user's code.

Typical Usage:

Required bean name is "Bit1".
Examples of a typical usage of this bean follow:

(1)
Required bean settings:
- Name: Bit1
- Direction: input

 MAIN.C

void main(void)
{
  ...
  
  /* Wait until logical "1" is on the pin */
  while( !Bit1_GetVal() );
  
  ...
}

(2) Required bean settings:
- Name: Bit1
- Direction: output

 MAIN.C

void main(void)
{
  ...
  
  for (;;) {
    Bit1_NegVal();  // Invert output level on the pin
  }
  
  ...
}

(3)
This example emulates an open drain output pin. The direction of the bean is set to input/output and the safe mode is disabled. External pull-up resistor should be connected to the pin.

Required bean settings:
- Name: Bit1
- Direction: input/output
- Safe mode: disabled
- pull-up: no pull resistor

 MAIN.C

void main(void)
{
  ...
  
  /* Set input mode. */
  Bit1_SetDir(FALSE);
  /* Logical "1" is on the pin */
  
  ...
  
  /* Set output mode */  
  Bit1_SetDir(TRUE);
  
  /* Set output value to "0" */
  Bit1_ClrVal();
/* Logical "0" is on the pin */
  
  ...
}

(4)
This example shows how the value written to the bean when it is set to the input direction is written to the output after the direction is switched to output. The safe mode is enabled and an external pull-up resistor should be connected to the pin.

Required bean settings:
- Name: Bit1
- Direction: input/output
- Safe mode: enabled
- Pull-up: no pull resistor

 MAIN.C

void main(void)
{
  ...

  /* Set input mode */		 
  Bit1_SetDir(FALSE);
  /* Logical "1" is on the pin */

  /* Set output value to "0", which will be
     applied when the bean will be set to output mode */
  Bit1_ClrVal();
   
  /* Set output mode */
  Bit1_SetDir(TRUE);
  /* Logical "0" is on the pin */
  
  ...
}

For more about typical usage of the bean code please refer to the page Bean Code Typical Usage.


Processor ExpertTM and Embedded BeansTM are registered trademarks of UNIS, Ltd.
©1997-2005, UNIS, Ltd.